// document.cookie="token=82b6f469b4bd613a1b2ee10bb4d0afabbf4d7865"
getCookie=function(name){
	var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr!=null)return unescape(arr[2]); return "";
}
var token= getCookie("token");
$(function(){
	//加载layer扩展样式
	layer.config({
	  extend: 'yourskin/style.css' //同样需要加载新皮肤
	});
	
	var pagelimit = 20;
	function pages(count, limit){
		var page = 0;
		if(count>0){
			
			var page = Math.ceil(count/limit);
			
			var pagetag = "";
			for (var k=1;k<=page;k++) {
				if(k==1){
					pagetag += '<li><a href="#" style="background:#ccc">'+k+'</a></li>';
				}else{
					pagetag += '<li><a href="#" >'+k+'</a></li>';
				}
								   
			}
			if(page<=1){
				var pagetag = "";
			}
			$('.pagination').html(pagetag);
			
		}
		
	
	}
	//左侧菜单悬停
	$(".list_menu li").hover(function(){
		var index=$(this).index()
		if(index==0||index==5||index==8){
			$(this).css('backgroundColor','#ffffff')
		}
		else {
			$(this).css('backgroundColor','#FEE631')
		}
	},function(){
		var index=$(this).index()
		if(index==6){
			$(this).css('backgroundColor','#FEE631')
		}
		else{
			$(this).css('backgroundColor','#ffffff')
		}
	})
	//	获取个人资料
	$.ajax({
		url:'http://ww.yc630.com/api/index.php/Buyer/User/userinfo',
		type:"post",
		data:{
			'token':token
		},
		dataType:"JSON",
		success:function(data){
			var avatar = data['data']['avatar'];
			if(avatar==''){
				avatar = '../img/Group%2019.png';
			}
			$("#headPic").attr('src',avatar)
		}
	})
	//获得商家信息
	$.ajax({
		type:"post",
		url:"http://ww.yc630.com/api/index.php/Buyer/Goods/sellerdetail",
		data:{
			'token':token
		},
		dataType:'json',
		success:function(data){
			$("#icon_img").attr('src',data.data.icon_image)
			$("#icon_name").html(data.data.name)
		}
	});
	$.ajax({
		type:"post",
		url:"http://ww.yc630.com/api/index.php/Seller/Order/orderList",	
		data:{'page':1,"pagelimit":pagelimit,'token':token},
		dataType:'json',
		success:function(phpdata){
			
			
			pages(phpdata['data']['count'],pagelimit);
			//建立查询状态
			$('.main_right').attr('search_name','');
			$('.main_right').attr('search_value','');
			var str = '<tr class="z_head" count ="'+phpdata['data']['count']+'"><td>序号</td><td>订单号</td><td>下单时间</td><td>收货人</td><td>手机号</td>	<td width="135">收货地址</td><td>推荐人</td><td>实付款</td><td>优惠券</td><td>订单状态</td><td width="100">操作</td></tr>';
			if(phpdata['code']==1){					
					str += '<tr><td colspan="11" style="color:#999">暂无搜索结果</td></tr>';
					$('.z_t').html(str);
					return false;
				}
			for(i in phpdata['data']['orders']){
				
				if(phpdata['data']['orders'][i]['status'] == 0){
						var status = '待付款';
						var make = '<a class="status0" href="###">关闭交易</a> <a href="###">调整价格</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 1){
						var status = '待发货';
						var make = '<a href="###">发货</a> <a href="###">关闭交易</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 2){
						var status = '已发货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 3){
						var status = '已关闭';
						var make = '<a href="###">删除</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 4){
						var status = '待评价';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 5){
						var status = '已评价';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 6){
						var status = '申请退货';
						var make = '<a href="###">同意退货</a> <a href="###">拒绝退货</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 7){
						var status = '拒绝退货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 8){
						var status = '待退货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 9){
						var status = '等待退货';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 10){
						var status = '已退货';
						var make = '<a href="###">同意退款</a> <a href="###">拒绝退款</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 11){
						var status = '等待退款';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 12){
						var status = '拒绝退款';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 13){
						var status = '退款成功';
						var make = '<a href="###">删除</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 14){
						var status = '平台仲裁';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 15){
						var status = '删除订单';
						var make = '';
					}
				
				str +='<tr class="z_list_main"><td>'+i+'</td><td>'+phpdata['data']['orders'][i]['orderid']+'</td><td>'+phpdata['data']['orders'][i]['createtime']+'</td><td>'+phpdata['data']['orders'][i]['recipients']+'</td><td>'+phpdata['data']['orders'][i]['mobile']+'</td><td style="line-height: 20px;">地址：'+phpdata['data']['orders'][i]['address']+'</td><td>'+phpdata['data']['orders'][i]['inviteid']+'</td><td>￥'+phpdata['data']['orders'][i]['real_money']+'</td><td>￥'+phpdata['data']['orders'][i]['freight']+'</td><td>'+status+'</td><td style="line-height: 25px;">'+make+'</td></tr>';
			}
			$('.z_t').html(str);
		}
	});
	//关键词搜索
	$(".keyname_btn").click(function(){
		var key_name_title = $('select[name="key_name_title"]').val();
		var keyword = $('input[name="keyword"]').val();
		
		if(!keyword){
			noticebox('提示','请输入关键字',1);
			return false;
		}
		
		    var datas = {};
			datas[key_name_title] =keyword;
			datas['page']=1;
			datas['pagelimit']=pagelimit;
			datas['token']=token;

		$.ajax({
			type:"post",
			url:"http://ww.yc630.com/api/index.php/Seller/Order/orderList",
			data:datas,
			dataType:'json',
			success:function(phpdata){
				pages(phpdata['data']['count'],pagelimit);
				//建立查询状态
				$('.main_right').attr('search_name',key_name_title);
				$('.main_right').attr('search_value',keyword);
				var str = '<tr class="z_head" search_name="'+key_name_title+'" search_name="'+keyword+'" ><td>序号</td><td>订单号</td><td>下单时间</td><td>收货人</td><td>手机号</td>	<td width="135">收货地址</td><td>推荐人</td><td>实付款</td><td>优惠券</td><td>订单状态</td><td width="100">操作</td></tr>';
				if(phpdata['code']==1){					
					str += '<tr><td colspan="11" style="color:#999">暂无搜索结果</td></tr>';
					$('.z_t').html(str);
					return false;
				}
				for(i in phpdata['data']['orders']){
					if(phpdata['data']['orders'][i]['status'] == 0){
						var status = '待付款';
						var make = '<a class="status0" href="###">关闭交易</a> <a href="###">调整价格</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 1){
						var status = '待发货';
						var make = '<a href="###">发货</a> <a href="###">关闭交易</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 2){
						var status = '已发货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 3){
						var status = '已关闭';
						var make = '<a href="###">删除</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 4){
						var status = '待评价';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 5){
						var status = '已评价';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 6){
						var status = '申请退货';
						var make = '<a href="###">同意退货</a> <a href="###">拒绝退货</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 7){
						var status = '拒绝退货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 8){
						var status = '待退货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 9){
						var status = '等待退货';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 10){
						var status = '已退货';
						var make = '<a href="###">同意退款</a> <a href="###">拒绝退款</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 11){
						var status = '等待退款';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 12){
						var status = '拒绝退款';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 13){
						var status = '退款成功';
						var make = '<a href="###">删除</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 14){
						var status = '平台仲裁';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 15){
						var status = '删除订单';
						var make = '';
					}
					
					str +='<tr class="z_list_main"><td>'+i+'</td><td>'+phpdata['data']['orders'][i]['orderid']+'</td><td>'+phpdata['data']['orders'][i]['createtime']+'</td><td>'+phpdata['data']['orders'][i]['recipients']+'</td><td>'+phpdata['data']['orders'][i]['mobile']+'</td><td style="line-height: 20px;">地址：'+phpdata['data']['orders'][i]['address']+'</td><td>'+phpdata['data']['orders'][i]['inviteid']+'</td><td>￥'+phpdata['data']['orders'][i]['real_money']+'</td><td>￥'+phpdata['data']['orders'][i]['freight']+'</td><td>'+status+'</td><td style="line-height: 25px;">'+make+'</td></tr>';
				}
				$('.z_t').html(str);
				$('#start').html('');
				$('#end').html('');
				$('.z_c_box').removeAttr("checked");
				}
		});
	})
	//按时间搜索
	$('.z_search_button').click(function(){
		var start_time = $('#start').html();
		var end_time = $('#end').html();
		if(!start_time){
			
			noticebox('提示','请输入开始时间',1);
			return false;
		}
		if(!end_time){

			noticebox('提示','请输入结束时间',1);
			return false;
		}
		var datas = {};
		datas['start_time'] =start_time;
		datas['end_time'] = end_time;
		datas['page']=1;
		datas['pagelimit']=pagelimit;
		datas['token']=token;
		$.ajax({
			type:"post",
			url:"http://ww.yc630.com/api/index.php/Seller/Order/orderList",
			data:datas,
			dataType:'json',
			success:function(phpdata){
				pages(phpdata['data']['count'],pagelimit);
				//建立查询状态
				$('.main_right').attr('search_name','time');
				$('.main_right').attr('search_value','');
				$('.main_right').attr('start_time',start_time);
				$('.main_right').attr('end_time',end_time);
				var str = '<tr class="z_head"><td>序号</td><td>订单号</td><td>下单时间</td><td>收货人</td><td>手机号</td>	<td width="135">收货地址</td><td>推荐人</td><td>实付款</td><td>优惠券</td><td>订单状态</td><td width="100">操作</td></tr>';
				if(phpdata['code']==1){					
					str += '<tr><td colspan="11" style="color:#999">暂无搜索结果</td></tr>';
					$('.z_t').html(str);
					return false;
				}
				for(i in phpdata['data']['orders']){
					if(phpdata['data']['orders'][i]['status'] == 0){
						var status = '待付款';
						var make = '<a class="status0" href="###">关闭交易</a> <a href="###">调整价格</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 1){
						var status = '待发货';
						var make = '<a href="###">发货</a> <a href="###">关闭交易</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 2){
						var status = '已发货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 3){
						var status = '已关闭';
						var make = '<a href="###">删除</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 4){
						var status = '待评价';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 5){
						var status = '已评价';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 6){
						var status = '申请退货';
						var make = '<a href="###">同意退货</a> <a href="###">拒绝退货</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 7){
						var status = '拒绝退货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 8){
						var status = '待退货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 9){
						var status = '等待退货';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 10){
						var status = '已退货';
						var make = '<a href="###">同意退款</a> <a href="###">拒绝退款</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 11){
						var status = '等待退款';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 12){
						var status = '拒绝退款';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 13){
						var status = '退款成功';
						var make = '<a href="###">删除</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 14){
						var status = '平台仲裁';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 15){
						var status = '删除订单';
						var make = '';
					}
					
					str +='<tr class="z_list_main"><td>'+i+'</td><td>'+phpdata['data']['orders'][i]['orderid']+'</td><td>'+phpdata['data']['orders'][i]['createtime']+'</td><td>'+phpdata['data']['orders'][i]['recipients']+'</td><td>'+phpdata['data']['orders'][i]['mobile']+'</td><td style="line-height: 20px;">地址：'+phpdata['data']['orders'][i]['address']+'</td><td>'+phpdata['data']['orders'][i]['inviteid']+'</td><td>￥'+phpdata['data']['orders'][i]['real_money']+'</td><td>￥'+phpdata['data']['orders'][i]['freight']+'</td><td>'+status+'</td><td style="line-height: 25px;">'+make+'</td></tr>';
				}
				$('.z_t').html(str);
				$('select[name="status"] option[value="0"]').attr('selected','selected');
				$('input[name="keyword"]').val('');
				$('.z_c_box').removeAttr("checked");
				}
		});
	})
	//按状态筛选
	$('select[name="status"]').change(function(){
		var stauts = $(this).val();
		if(stauts==0){
			noticebox('提示','请选择状态',1);
			return false;
		}
		var datas = {};
		datas['status'] =stauts;	
		datas['page']=1;
		datas['pagelimit']=pagelimit;
		datas['token']=token;
		$.ajax({
			type:"post",
			url:"http://ww.yc630.com/api/index.php/Seller/Order/orderList",
			data:datas,
			dataType:'json',
			success:function(phpdata){
				pages(phpdata['data']['count'],pagelimit);
				//建立查询状态
				$('.main_right').attr('search_name','status');
				$('.main_right').attr('search_value',stauts);
				var str = '<tr class="z_head"><td>序号</td><td>订单号</td><td>下单时间</td><td>收货人</td><td>手机号</td>	<td width="135">收货地址</td><td>推荐人</td><td>实付款</td><td>优惠券</td><td>订单状态</td><td width="100">操作</td></tr>';
				if(phpdata['code']==1){					
					str += '<tr><td colspan="11" style="color:#999">暂无搜索结果</td></tr>';
					$('.z_t').html(str);
					return false;
				}
				for(i in phpdata['data']['orders']){
					if(phpdata['data']['orders'][i]['status'] == 0){
						var status = '待付款';
						var make = '<a class="status0" href="###">关闭交易</a> <a href="###">调整价格</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 1){
						var status = '待发货';
						var make = '<a href="###">发货</a> <a href="###">关闭交易</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 2){
						var status = '已发货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 3){
						var status = '已关闭';
						var make = '<a href="###">删除</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 4){
						var status = '待评价';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 5){
						var status = '已评价';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 6){
						var status = '申请退货';
						var make = '<a href="###">同意退货</a> <a href="###">拒绝退货</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 7){
						var status = '拒绝退货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 8){
						var status = '待退货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 9){
						var status = '等待退货';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 10){
						var status = '已退货';
						var make = '<a href="###">同意退款</a> <a href="###">拒绝退款</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 11){
						var status = '等待退款';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 12){
						var status = '拒绝退款';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 13){
						var status = '退款成功';
						var make = '<a href="###">删除</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 14){
						var status = '平台仲裁';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 15){
						var status = '删除订单';
						var make = '';
					}
					
					str +='<tr class="z_list_main"><td>'+i+'</td><td>'+phpdata['data']['orders'][i]['orderid']+'</td><td>'+phpdata['data']['orders'][i]['createtime']+'</td><td>'+phpdata['data']['orders'][i]['recipients']+'</td><td>'+phpdata['data']['orders'][i]['mobile']+'</td><td style="line-height: 20px;">地址：'+phpdata['data']['orders'][i]['address']+'</td><td>'+phpdata['data']['orders'][i]['inviteid']+'</td><td>￥'+phpdata['data']['orders'][i]['real_money']+'</td><td>￥'+phpdata['data']['orders'][i]['freight']+'</td><td>'+status+'</td><td style="line-height: 25px;">'+make+'</td></tr>';
				}
				$('.z_t').html(str);				
				$('input[name="keyword"]').val('');
				$('#start').html('');
				$('#end').html('');
				$('.z_c_box').removeAttr("checked");
				}
		});
	})
	
	
	$('.pagination').on('click','li a',function(){
		//获取当前页码
		var pagenum = $(this).html();
		//改变背景颜色
		$(this).css('background','#ccc');
		$(this).parents('li').siblings('li').find('a').css('background','#FFF')
		//记录查询状态
		var search_name = $('.main_right').attr('search_name');
		var search_value = $('.main_right').attr('search_value');
		        var datas = {};
		        datas['page']=pagenum;
		        datas['pagelimit']=pagelimit;
				datas['token']=token;
				if(search_name!=''){
					if(search_name=='time'){
						var start_time=$('.main_right').attr('start_time');
						var end_time=$('.main_right').attr('end_time');
						datas['start_time']=start_time;
						datas['end_time']=end_time;
					}else{
						datas[search_name] =search_value;
						
					}
					
						
				}
					
				$.ajax({
					type:"post",
					url:"http://ww.yc630.com/api/index.php/Seller/Order/orderList",
					data:datas,
					dataType:'json',
					success:function(phpdata){
						var str = '<tr class="z_head"><td>序号</td><td>订单号</td><td>下单时间</td><td>收货人</td><td>手机号</td>	<td width="135">收货地址</td><td>推荐人</td><td>实付款</td><td>优惠券</td><td>订单状态</td><td width="100">操作</td></tr>';
						if(phpdata['code']==1){					
							str += '<tr><td colspan="11" style="color:#999">暂无搜索结果</td></tr>';
							$('.z_t').html(str);
							return false;
						}
						for(i in phpdata['data']['orders']){
							if(phpdata['data']['orders'][i]['status'] == 0){
						var status = '待付款';
						var make = '<a class="status0" href="###">关闭交易</a> <a href="###">调整价格</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 1){
						var status = '待发货';
						var make = '<a href="###">发货</a> <a href="###">关闭交易</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 2){
						var status = '已发货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 3){
						var status = '已关闭';
						var make = '<a href="###">删除</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 4){
						var status = '待评价';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 5){
						var status = '已评价';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 6){
						var status = '申请退货';
						var make = '<a href="###">同意退货</a> <a href="###">拒绝退货</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 7){
						var status = '拒绝退货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 8){
						var status = '待退货';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 9){
						var status = '等待退货';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 10){
						var status = '已退货';
						var make = '<a href="###">同意退款</a> <a href="###">拒绝退款</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 11){
						var status = '等待退款';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 12){
						var status = '拒绝退款';
						var make = '<a href="###">查看</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 13){
						var status = '退款成功';
						var make = '<a href="###">删除</a>';
					}
					if(phpdata['data']['orders'][i]['status'] == 14){
						var status = '平台仲裁';
						var make = '';
					}
					if(phpdata['data']['orders'][i]['status'] == 15){
						var status = '删除订单';
						var make = '';
					}
							
							str +='<tr class="z_list_main"><td>'+i+'</td><td>'+phpdata['data']['orders'][i]['orderid']+'</td><td>'+phpdata['data']['orders'][i]['createtime']+'</td><td>'+phpdata['data']['orders'][i]['recipients']+'</td><td>'+phpdata['data']['orders'][i]['mobile']+'</td><td style="line-height: 20px;">地址：'+phpdata['data']['orders'][i]['address']+'</td><td>'+phpdata['data']['orders'][i]['inviteid']+'</td><td>￥'+phpdata['data']['orders'][i]['real_money']+'</td><td>￥'+phpdata['data']['orders'][i]['freight']+'</td><td>'+status+'</td><td style="line-height: 25px;">'+make+'</td></tr>';
						}
						$('.z_t').html(str);	
						$('.z_c_box').removeAttr("checked");
						
						}
				});
			})
   $('.z_c_box').click(function(){
   	if($(this).is(':checked')){
   		$('.status0').parents('tr').css('display','none');
   	}else{
   		$('.status0').parents('tr').css('display','');
   	}
   })
   $('.z_t').on('click','.z_list_main td a',function(){
     //获取a标签的内容
     var a_html=$(this).html();   	
   	 var orderid = $(this).parents('.z_list_main').find('td:nth-child(2)').html();
   	 var buyer = $(this).parents('.z_list_main').find('td:nth-child(4)').html();
   	 var truemoney = $(this).parents('.z_list_main').find('td:nth-child(8)').html();
   	 if(a_html=='关闭交易'){
   	 	
   	 	layer.open({
		  content: '确定关闭交易吗'
		  ,btn: ['确定', '取消']
		  ,skin:'yourclass'
		  ,yes: function(index, layero){
		    $.ajax({
     			type:"post",
     			url:"http://ww.yc630.com/api/index.php/Seller/Order/close_order",
     			data:{'orderid':orderid,'token':token},
     			dataType:'json',
     			success:function(phpdata){
     				if(phpdata['code']==0){    					
     					location.reload();
     				}else if(phpdata['code']==1){
     					
     					location.reload();
     				}
     			}
     			
     		});
		  }
		  ,cancel: function(){ 
		    
		  }
		});
   	 	    	
     }
   	 if(a_html=='删除'){
   	 	
   	 	layer.open({
		  content: '确定删除吗'
		  ,btn: ['确定', '取消']
		  ,skin:'yourclass'
		  ,yes: function(index, layero){
		    $.ajax({
     			type:"post",
     			url:"http://ww.yc630.com/api/index.php/Seller/Order/delete_order",
     			data:{'orderid':orderid,'type':1,'token':token},
     			dataType:'json',
     			success:function(phpdata){
     				if(phpdata['code']==0){    					
     					location.reload();
     				}else if(phpdata['code']==1){
     					location.reload();
     				}
     				
     			}
     			
     		});
		  }
		  ,cancel: function(){ 
		    
		  }
		});
   	 	
     }
   	 
   	 if(a_html=='同意退货'){
   	 	
   	 	layer.open({
		  content: '确定买家退货吗'
		  ,btn: ['确定', '取消']
		  ,skin:'yourclass'
		  ,yes: function(index, layero){
		    $.ajax({
     			type:"post",
     			url:"http://ww.yc630.com/api/index.php/Seller/Order/agree_return_goods",
     			data:{'orderid':orderid,'token':token},
     			dataType:'json',
     			success:function(phpdata){
     				if(phpdata['code']==0){
     					
     					location.reload();
     				}else if(phpdata['code']==1){
     					
     					location.reload();
     				}
     				
     			}
     			
     		});
		  }
		  ,cancel: function(){ 
		    
		  }
		});
   	 	
   	 	
     }
   	 if(a_html=='同意退款'){
   	 	layer.open({
		  type: 1,
		  title: '同意退款',
		  closeBtn: 0,
		  area: ['420px', '300px'], //宽高
		  shadeClose: true,
		  skin: 'yourclass',
		  content: '<table style="width:50%;text-align:center;margin:0 auto;" border="0" cellspacing="0" cellpadding="0" ><tr><td height="42">买家：</td><td>'+buyer+'</td></tr><tr><td height="42">支付金额：</td><td>'+truemoney+'元</td></tr><tr><td height="42">退款金额：</td><td><input type="text" name="refund" style="width:50px;height:30px" /></td></tr><tr><td height="42">备注：</td><td><input type="text" name="remark" style="width:100px;height:30px" /></td></tr></table>'
		  ,btn: ['确定', '取消']
		  ,yes: function(index, layero){
		  	var refund = $('input[name="refund"]').val();
		  	var remark = $('input[name="remark"]').val();
		  	if(refund==''){		  		
		  		noticebox('提示','退款金额不能为空',1);
		  		return false;
		  	}
		  	if(isNaN(refund) || refund<0){
		  		noticebox('提示','请合法输入信息',1);
		  		return false;
		  	}
		  	
		  	$.ajax({
		  		type:"post",
		  		url:"http://ww.yc630.com/api/index.php/Seller/Order/agree_refund",
		  		data:{'orderid':orderid,'refund':refund,'remark':remark,'token':token},
		  		dataType:'json',
		  		success:function(phpdata){
		  			if(phpdata['code']==0){
		  				
		  				location.reload();
		  			}else{
		  				
		  				location.reload();
		  			}
		  		}
		  	});
		    
		  },btn2: function(index, layero){
		    
		  }
		});
   	 }
   	 
   	 if(a_html=='调整价格'){
   	 	layer.open({
		  type: 1,
		  title: '调整价格',
		  closeBtn: 0,
		  area: ['420px', '300px'], //宽高
		  shadeClose: true,
		  skin: 'yourclass',
		  content: '<table style="width:50%;text-align:center;margin:0 auto;" border="0" cellspacing="0" cellpadding="0" ><tr><td height="42">买家：</td><td>'+buyer+'</td></tr><tr><td height="42">支付金额：</td><td>'+truemoney+'元</td></tr><tr><td height="42">调整为：</td><td><input type="text" name="after_change_money" style="width:50px;height:30px" />元</td></tr></table>'
		  ,btn: ['确定', '取消']
		  ,yes: function(index, layero){
		  	var after_change_money = $('input[name="after_change_money"]').val();
		  
		  	if(after_change_money==''){		  		
		  		noticebox('提示','金额不能为空',1);
		  		return false;
		  	}
		  	if(isNaN(after_change_money) || after_change_money<0){

		  		noticebox('提示','请合法输入信息',1);
		  		return false;
		  	}
		  	
		  	$.ajax({
		  		type:"post",
		  		url:"http://ww.yc630.com/api/index.php/Seller/Order/changeOrdermoney",
		  		data:{'orderid':orderid,'after_change_money':after_change_money,'token':token},
		  		dataType:'json',
		  		success:function(phpdata){
		  			if(phpdata['code']==0){
		  				
		  				location.reload();
		  			}else{
		  				
		  				location.reload();
		  			}
		  		}
		  	});
		    
		  },btn2: function(index, layero){
		    
		  }
		});
   	 }
   	 
   	 if(a_html=='发货'){
   	 	var time = "{istime: true,format: 'YYYY-MM-DD hh:mm:ss'}";
   	 	
   	 	var content ='<table style="width:70%;text-align:left;margin:0 auto;" border="0" cellspacing="0" cellpadding="0" ><tr><td height="42">配送方式：</td><td><select name="expresses_company">';
   	 	
   	 	//获取快递公司列表
   	 	$.ajax({
   	 		type:"post",
   	 		url:"http://ww.yc630.com/api/index.php/Seller/Freight/freight_company",
   	 		data:{
				'token':token
			},
   	 		dataType:'json',
   	 		async: false,
   	 		success:function(phpdata){
   	 			
   	 			for(i in phpdata['data']){
   	 				content += '<option value="'+phpdata['data'][i]['ex_id']+'">'+phpdata['data'][i]['ex_name']+'</option>';
   	 			}
   	 			
   	 		}
   	 	});
   	 	content += '</select></td></tr><tr><td height="42">发货时间：</td><td><div style="width:163px;height:35px" id="expresses_time" class="laydate-icon" onclick="laydate('+time+')"></div></td></tr><tr><td height="42">发货单号：</td><td><input type="text" name="expresses_nu" style="width:180px;height:30px" /></td></tr><tr><td height="42">实际运费：</td><td><input type="text" name="real_freight" style="width:180px;height:30px" /></td></tr></table>';
   	 	
   	 	layer.open({
		  type: 1,
		  title: '确认发货',
		  closeBtn: 0,
		  area: ['420px', '300px'], //宽高
		  shadeClose: true,
		  skin: 'yourclass',
		  content: content
		  ,btn: ['确定', '取消']
		  ,yes: function(index, layero){
		  	var expresses_time = $('#expresses_time').html();
		  	var expresses_nu = $('input[name="expresses_nu"]').val();
		    var real_freight = $('input[name="real_freight"]').val();
		    var expresses_company = $('select[name="expresses_company"]').val();
		  	if(expresses_time==''){
		  		
		  		noticebox('提示','发货时间不能为空',1);
		  		return false;
		  	}
		  	if(expresses_nu==''){

		  		noticebox('提示','快递单号不能为空',1);
		  		return false;
		  	}
		  	if(real_freight == ''){

		  		noticebox('提示','运费不能为空',1);
		  		return false;
		  	}
		  	if(isNaN(real_freight) || real_freight<0){

		  		noticebox('提示','请输入正确的运费金额',1);
		  		return false;
		  	}
		  	
		  	$.ajax({
		  		type:"post",
		  		url:"http://ww.yc630.com/api/index.php/Seller/Order/confirmshipment",
		  		data:{'orderid':orderid,'expresses_time':expresses_time,'expresses_company':expresses_company,'expresses_nu':expresses_nu,'real_freight':real_freight,'token':token},
		  		dataType:'json',
		  		success:function(phpdata){
		  			if(phpdata['code']==0){
		  				
		  				location.reload();
		  			}else{
		  				
		  				location.reload();
		  			}
		  		}
		  	});
		    
		  },btn2: function(index, layero){
		    
		  }
		});
   	 }
   	 
   	 

   })
})
